<template>
    <div>
        <div class="top_box container_box">
            <p class="page-title font-weight-500">修改密码</p>
        </div>
        <div class="padding_box">
            <div class="container_box">
                <div class="crumbs">
                    <el-breadcrumb separator="/">
                        <el-breadcrumb-item>
                            <i class="el-icon-lx-cascades"></i> 修改密码
                        </el-breadcrumb-item>
                    </el-breadcrumb>
                </div>

                <div class="pass-input">
                    <div class="title">原密码：</div>
                    <el-input placeholder="请输入原密码"
                              v-model="oldPassWord"
                              show-password></el-input>
                </div>
                <div class="pass-input">
                    <div class="title">新密码：</div>
                    <el-input placeholder="请输入新密码"
                              v-model="password1"
                              show-password></el-input>
                </div>
                <div class="pass-input">
                    <div class="title">确认新密码：</div>
                    <el-input placeholder="请再次输入新密码"
                              v-model="password2"
                              show-password></el-input>
                </div>
                <div class="pass-input">
                    <div class="title"></div>
                    <el-button type="primary"
                               @click="changePassWord">确认修改</el-button>
                </div>
            </div>
        </div>
    </div>
</template>


<script>
import axios from '@/utils/axios.js';
import bus from '@/common/bus.js';
export default {
    data: function () {
        return {
            oldPassWord: '',
            password1: '',
            password2: '',
            userId: ''

        };
    },
    created() {
    },
    activated() {
    },
    methods: {
        changePassWord() {
            if (this.oldPassWord == '' || this.password1 == '' || this.password2 == '') {
                return this.$message.error("请填写完整")
            }
            if (this.password1 != this.password2) {
                this.password1 = ''
                this.newPassWord2 = ''
                this.password2 = ''
                return this.$message.error("两次密码输入不一致请重新输入")

            }
            const data = {
                oldPassword: this.oldPassWord,
                password: this.password1,
            }
            axios({
                url: "/adminUser/update",
                method: "post",
                data
            }).then(result => {
                if (result.code == 0) {
                    this.$message.success('修改成功');
                    this.$router.push('/dashboard');
                } else {
                    this.$message.error(result.errMsg || '修改失败');
                }

            })
        }
    },


};
</script>

<style scoped>
.title {
    width: 140px;
    min-width: 140px;
    height: 32px;
    line-height: 32px;
    text-align: right;
    font-size: inherit;
    color: #999999;
}
.pass-input {
    width: 50%;
    height: 32px;
    display: flex;
    margin-top: 16px;
}
.button {
    margin-top: 16px;
    margin-left: 140px;
}
</style>